package jp.sourceforge.akjrcp.text_douga.rcp;



import jp.sourceforge.akjrcp.ffmpeg.FFMpegCodecs;

import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class TextDougaAviPage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
	
	public static final int RATE_8000=8000;
	public static final int RATE_11025=11025;
	public static final int RATE_12000=12000;
	public static final int RATE_16000=16000;
	public static final int RATE_22050=22050;
	public static final int RATE_24000=24000;
	public static final int RATE_32000=32000;
	public static final int RATE_44100=44100;
	public static final int RATE_48000=48000;
	
    //public static final String EXPORT_WAVE_SAMPLEBIT = "export.wave.samplebit"; //$NON-NLS-1$
	public static final String AUDIO_RATE = "textdouga.audio_samplerate"; //$NON-NLS-1$
	public static final String AUDIO_CHANNEL = "textdouga.audio_channel"; //$NON-NLS-1$
    public static final String FFMPEG_OPTION="textdouga.ffmpeg_option"; //$NON-NLS-1$
    public static final String AUDIO_BITRATE="textdouga.audio_bitrate"; //$NON-NLS-1$
    public static final String VIDEO_BITRATE="textdouga.video_bitrate"; //$NON-NLS-1$

	public static final String AVI_VIDEO_CODEC="textdouga.avisetting.video";
	public static final String AVI_AUDIO_CODEC="textdouga.avisetting.audio";
	
	public TextDougaAviPage() {
		super(GRID);
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
		setDescription(Messages.getString("textdouga.avi_description")); //$NON-NLS-1$
		
		initializeDefaults();
	}
	
	private void initializeDefaults() {
		
		// no one call it before open them

	}

	protected void createFieldEditors() {
	   	 addField(new RadioGroupFieldEditor(
	         		AVI_VIDEO_CODEC,
	 				Messages.getString("wmvsetting.video"), // //$NON-NLS-1$
	 				2,
	 				new String[][] { 
	 				{ Messages.getString("avisetting.msjpg"), FFMpegCodecs.VIDEO_MJPEG }, //$NON-NLS-1$ //$NON-NLS-2$
	 				{ Messages.getString("avisetting.xvid"), FFMpegCodecs.VIDEO_XVID }, //$NON-NLS-1$ //$NON-NLS-2$
	 				{ Messages.getString("wmvsetting.msmpeg4v1"), FFMpegCodecs.VIDEO_MSMPEG4V1 }, //$NON-NLS-1$ //$NON-NLS-2$
	 				{ Messages.getString("wmvsetting.msmpeg4v2"), FFMpegCodecs.VIDEO_MSMPEG4V2 }, //$NON-NLS-1$ //$NON-NLS-2$
	 				{ Messages.getString("avisetting.h264"), FFMpegCodecs.VIDEO_H264 }, //$NON-NLS-1$ //$NON-NLS-2$
	 				{ Messages.getString("avisetting.huffyuv"), FFMpegCodecs.VIDEO_HUFFYUV },
	 				{ Messages.getString("avisetting.copy"), FFMpegCodecs.COPY }
	 			}, getFieldEditorParent()));

    	addField(new IntegerFieldEditor(VIDEO_BITRATE,Messages.getString("textdouga.video_bitrate"),getFieldEditorParent())); //$NON-NLS-1$
    	
        addField(new RadioGroupFieldEditor(
         		AVI_AUDIO_CODEC,
 				Messages.getString("wmvsetting.audio"), // //$NON-NLS-1$
 				2,
 				new String[][] { 
 				{ Messages.getString("wmvsetting.wmav1"), FFMpegCodecs.AUDIO_WMA1 }, //$NON-NLS-1$ //$NON-NLS-2$
 				{ Messages.getString("wmvsetting.wmav2"), FFMpegCodecs.AUDIO_WMA2 }, //$NON-NLS-1$ //$NON-NLS-2$
 				{ Messages.getString("avisetting.mp3"), FFMpegCodecs.AUDIO_MP3 }, //$NON-NLS-1$ //$NON-NLS-2$
 				{ Messages.getString("avisetting.wav"), FFMpegCodecs.AUDIO_WAV },
 				
 				
 			}, getFieldEditorParent()));
        
        addField(new RadioGroupFieldEditor(
		        AUDIO_RATE,
				Messages.getString("textdouga.sample_rate"), // //$NON-NLS-1$
				4,
				new String[][] { { TextDougaAviPage.RATE_8000+" khz", TextDougaAviPage.RATE_8000+"" }, { //$NON-NLS-1$ //$NON-NLS-2$
					TextDougaAviPage.RATE_11025+" khz", TextDougaAviPage.RATE_11025+""   //$NON-NLS-1$ //$NON-NLS-2$
				    
				},
				{ TextDougaAviPage.RATE_12000+" hz", TextDougaAviPage.RATE_12000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ TextDougaAviPage.RATE_16000+" hz", TextDougaAviPage.RATE_16000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ TextDougaAviPage.RATE_22050+" hz", TextDougaAviPage.RATE_22050+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ TextDougaAviPage.RATE_24000+" hz", TextDougaAviPage.RATE_24000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ TextDougaAviPage.RATE_32000+" hz", TextDougaAviPage.RATE_32000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ TextDougaAviPage.RATE_44100+" hz", TextDougaAviPage.RATE_44100+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ TextDougaAviPage.RATE_48000+" hz", TextDougaAviPage.RATE_48000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				
			}, getFieldEditorParent()));
        
		addField(new RadioGroupFieldEditor(
		        AUDIO_CHANNEL,
			Messages.getString("textdouga.channel"), //$NON-NLS-1$
			2,
			new String[][] { { Messages.getString("stereo"), "2" }, {Messages.getString("monoral") ,"1"}}, getFieldEditorParent())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
       
		addField(new IntegerFieldEditor(AUDIO_BITRATE,Messages.getString("textdouga.audio_bitrate"),getFieldEditorParent())); //$NON-NLS-1$
        
        addField(new StringFieldEditor(FFMPEG_OPTION,Messages.getString("textdouga.ffmpeg_option"),getFieldEditorParent())); //$NON-NLS-1$
        
        
	}

	public void init(IWorkbench workbench) {
		// TODO Auto-generated method stub
		
	}

}
